const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
const ZonnarPlugin = require('../src/plugins/index.js')

module.exports = {
    mode:'none',
    // 代表上下文的执行路径。
    context: path.resolve(process.cwd()),
    entry:{
        app: "./src/app.js",
        root: "./src/index.js"
    },
    output:{
        // publicPath:'/static/',
        sourcePrefix: '\t',

        path: path.resolve(process.cwd(), './dist01'),
        scriptType: 'module',
        filename:"[name].[chunkhash:8].js",
        chunkFilename:"[name].chunk.[chunkhash:8].js"
    },
    optimization: {
        runtimeChunk: {
          name: 'runtime',
        },
      },
    module:{
        rules:[
            {
                test: /\.js$/,
                use:[
                    { loader: 'babel-loader'},
                ],
                include: path.resolve(process.cwd(), '/src/'),
                exclude: path.resolve(process.cwd(), '/node_modules/')
            }
        ]
    },
    plugins:[
        new webpack.ProgressPlugin(),
        new CleanWebpackPlugin(),
        new HTMLWebpackPlugin({ template: './public/index.html'}),
        new ZonnarPlugin({
            outputFile: 'assets.md'
        }),

    ]
}